<?php
/**
 * 描述：交易频道-采购信息页。
 * @final
 */
final class Exec_Transaction_Procurement_Info extends Exec
{
    public function Get()
    {
        #获取参数
        $id=Functions::UrlArgs('id');
        if(!is_numeric($id))
        {
            echo 'error';
            return;
        }

        #获取采购信息数据
        $procurement=DB::GetRowByID('procurement',$id);
        if($procurement)
        {
            $procurement['ThumbnailPath']=Config::PATH_RELATIVE_ATTACHMENT_TEMP.'/'.$procurement['ThumbnailPath'];
            $procurement['ClassName']=DAO_Category::GetNameByID($procurement['ClassID']);
            $procurement['SubclassName']=DAO_Category::GetNameByID($procurement['SubclassID']);
            View::Assign('Procurement',$procurement);
        }
        else
        {
            echo 'error:procurement';
            return;
        }

        #account
        $account=DB::PGetRows('select * from account where Username=?',array($procurement['Account']));
        if($account)
        {
            //是否VIP会员
            $tmp=DB::PGetRows('select * from account_vip where Account=? limit 0,1',array($account[0]['Username']));
            $account[0]['IsVip']='FALSE';
            if($tmp){
                $account[0]['IsVip']='TRUE';
            }
        }
        View::Assign('Account',@$account[0]);

        #获取相同用户相同类别的供应信息数据
        $procurements=DB::PGetRows('select * from Procurement where Account=? and ClassID=? and SubclassID=? and ID<>? order by Datetime desc ',array(
            $procurement['Account'],
            $procurement['ClassID'],
            $procurement['SubclassID'],
            $id
        ));
        View::Assign('Procurements',$procurements);

        #渲染输出
        View::Display('transaction/procurement/info.tpl');
    }
}
?>